<?php
/**
* This is controller use for public area
* @author: phutp@younetco.com
* @version: 0.1
*/


class Store_IndexController extends YouNet_Controller_Action{
	
	public function preDispatch() {
		parent::preDispatch();
	}
	/**
	* This action is the first view when accessing the app
	*/
	public function indexAction()
	{
		$this->_redirect($this->view->url(array('action' => 'list','controller' => 'store')), array('prependBase' => false));
	}
    
    public function notifyAction()
    {
        $this->disableAutoRender();
        $product = Core_Model_DbTable_Products::getInstance()->getProductForNotify($this->_params['id_page'], $this->_params['id_store'], $this->_params['id_product']);
        if(!empty($product))
        {
            if(!empty($product['email_mods']))
            {
                $email_mods = preg_replace('/\s+/', "", $product['email_mods']);
                $from       = "support@younetmedia.com";
                $to         = explode( ",", $email_mods);

                $data_send = array(
                    "url"       => $product->getShareUrl(array('id_page' => $product['id_page'])),
                    'name'      => $product->page_name,
                    "message"	=> $this->_params['message'],
                    "time"		=> $this->_params['time'],
                    "user_name" => $this->_user['name'],
                    "user_id"	=> $this->_params['user_id'],
                    "page_name" => $product->page_name,
                    "object_name"   => $product->name
                );

                $mailer = new YouNet_Mail();
                $mailer->sendCommentNotification($to, $data_send);
            }
        }
    }
}